using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

// 启动的时候自动添加场景
// https://blog.csdn.net/QQhelphelp/article/details/109702537
[InitializeOnLoad]
public class AutoAddScenes
{

    static AutoAddScenes()
    {
        // FindAssets 直接从 Assets 开始， Application.dataPath + "/Scenes" 是错的
        string SceneDirectory = $"Assets/Scenes";

        Debug.Log($"{SceneDirectory}");

        string[] scenePaths = AssetDatabase.FindAssets("t:Scene", new[] { SceneDirectory });

        Debug.Log($"scenePaths {scenePaths.Length}");
        EditorBuildSettingsScene[] buildScenes = new EditorBuildSettingsScene[scenePaths.Length];

        for (int i = 0; i < scenePaths.Length; i++)
        {
            string scenePath = AssetDatabase.GUIDToAssetPath(scenePaths[i]);
            buildScenes[i] = new EditorBuildSettingsScene(scenePath, true);
        }

        EditorBuildSettings.scenes = buildScenes;
    }

}
